{extend name="public/base"}

{block name="title"}就行天下-活动{/block}

{block name="style"}
<link rel="stylesheet" href="__STATIC__/home/css/personal.css" />
<style>
    .apply-list {
        margin: .5rem 0;
    }
</style>
{/block}

{block name="main"}
<div class="pageControl bg-f5">
    <div class="main-top"></div>
    <div class="msui_nav msui_navTop">
        <a class="msui_navTop-back" href="javascript:history.back();"><i class="micon-back"></i></a>
        <h1 class="msui_navTop-title">活动赞助</h1>
        <a href="" class="msui_navTop-right msui_navTop-cnav"><i class="micon-cnav"></i></a>
    </div>
    <div class="weui-cells__tips" style="margin-bottom: 10px;">
        <p class="fs08 cl-0000">本次活动可以申请赞助</p>
        <p>赞助商品可以在申请的店铺领取</p>
        <p>赞助商品需要按价格支付等额押金</p>
        <p>活动结束后，实际参与人数大于赞助人数要求押金可全额返还</p>
        <p class=" cl-0000">不需要赞助 <a class="repertory-btn1" style="position: inherit;" href="{:url('order/pay')}?model=activity&id={$id}">下一步</a> </p>
    </div>
    {volist name="data" id="vo"}
    <div class="apply-list">
        <div class="weui-cell weui-cell_access radiusImg">
            <div class="weui-cell__hd">
                <img src="{$vo.logo}" alt="">
            </div>
            <div class="weui-cell__bd">
                <p class="fs06 cl-3333">{$vo.s_name}</p>
            </div>
            <div class="weui-cell__ft">

            </div>
        </div>
        <div>
            <div class="swiper-container">
                <div class="swiper-wrapper">
                    {volist name="vo.product_image" id="v"}
                    <div class="swiper-slide">
                        <a href="javascript:;" style="display: block;"><img src="{$v.thumb}" alt="" style="width:100%;"/></a>
                    </div>
                    {/volist}
                </div>
                <div class="swiper-pagination"></div>
            </div>
        </div>
        <div class="weui-cell repertory repertory_unline">
            <div class="weui-cell__bd fs06 cl-9999">
                <p>赞助物品：<span>{$vo.p_name}</span></p>
                <p class="mtop03">价格：￥<span>{$vo.price}</span></p>
                <p>赞助人数：<span>{$vo.sponsor_num}</span></p>
            </div>

            <div class="weui-cell__ft">
                <p class="inventory fs06">剩余<span class="cl-c40">{$vo.inventory}</span>份</p>
                <button class="repertory-btn1 apply-for-sponsor" data-shop-id="{$vo.shop_id}" data-product-id="{$vo.product_id}">申请</button>
            </div>
        </div>
    </div>
    {/volist}
</div>
{/block}

{block name="javascript"}
<script type="text/javascript" src="__STATIC__/home/jquery_weui/js/swiper.min.js"></script>
<script>
    $(function () {
        var swiper = new Swiper('.swiper-container', {
            pagination: '.swiper-pagination',
            slidesPerView: 1,
            loop:true,
            paginationClickable: true,
            spaceBetween: 5,
            autoplay:3000
        });

        $('.apply-for-sponsor').click(function () {
            var _this = $(this);
            $.confirm('每个活动只能申请一个赞助，确认申请？', function () {
                $.ajax({
                    type : 'POST',
                    url : '{:url("apply_for_sponsor")}',
                    data : {
                        id : '{$id}',
                        shop_id : _this.data('shop-id'),
                        product_id : _this.data('product-id'),
                    },
                    dataType : 'json',
                    success : function (msg) {
                        if (msg.code == 200) {
                            $.toptip('申请成功！', 'success');
                            setTimeout(function () {
                                window.location.href = "{:url('order/pay')}?model=activity&id={$id}";
                            }, 888)
                        } else {
                            $.toptip(msg.msg);
                        }
                    }
                });
            });
        });
    })
</script>
{/block}